<!DOCTYPE html>
<html lang="ch">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
    <link rel="stylesheet" href="css/main.css">
    <link rel="stylesheet" href="css/create-code.css">
</head>
<body>
<div class="left-right">
    <div class="title-div">
        <input type="text" class="title-input" maxlength="13" id="title">
    </div>
    <div class="type-div">
        <input type="text" class="type-input" id="labels">
    </div>
    <div class="resume-div">
        <textarea id="resume"></textarea>
    </div>
    <div class="submit-line-div">
        <div class="submit-white-div">

        </div>
        <div class="submit-div">
            <input type="submit" value="发表" class="submit-input" id="addCode">
        </div>
    </div>
</div>
<div class="mid">
    <div class="mid-white"></div>
    <div class="mid-gray"></div>
    <div class="mid-white"></div>
</div>
<div class="left-right ">
    <textarea tabindex="-1" id="code"></textarea>
</div>
<script>
    $("#addCode").click(function () {
        var title = $("#title").val()
        var labels = $("#labels").val();
        var resume = $("#resume").val();
        var code = $("#code").val();
        $.ajax({
            url: "/code/create",
            type: "post",
            dataType: "text",
            data: "title=" + title + "&labels=" + labels + "&resume=" + resume + "&code=" + code,
            statusCode: {
                200: function (data) {
                    if (data.indexOf("true") !== -1) {
                        alert("success")
                    } else {
                        alert("fail add")
                    }
                }
            }
        })
    })
</script>
</body>
</html>